import CryptoJS from 'crypto-js';
const secret = 'to985qpiadf8ww2caqpq2fadf7q2';
/**
 * 加密函数
 * @param str
 * @returns {string}
 */
const encrypt = function (str) {
  if (typeof str !== 'string') {
    str += '';
  }
  const ciphertext = CryptoJS.AES.encrypt(str, secret).toString();
  return ciphertext;
};

/**
 * 解密
 * @param str
 * @returns {string}
 */
const decrypt = function (str) {
  const bytes = CryptoJS.AES.decrypt(str, secret);
  const originalText = bytes.toString(CryptoJS.enc.Utf8);
  return originalText;
};
export { encrypt, decrypt };
